6dc014
@@ -285,6 +285,8 @@
public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
         //check for the special header to force completion of all groups (and ignore the exchange otherwise)
         boolean completeAllGroups = exchange.getIn().getHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS, false, boolean.class);
         if (completeAllGroups) {
+            // remove the header so we do not complete again
+            exchange.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS);
             forceCompletionOfAllGroups();
             return;
         }
@@ -316,6 +318,12 @@
public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
                 // copy exchange, and do not share the unit of work
                 // the aggregated output runs in another unit of work
                 Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
+
+                // remove the complete all groups headers as it should not be on the copy
+                copy.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP);
+                copy.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS);
+                copy.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE);
+
                 try {
                     aggregated = doAggregation(key, copy);
                     exhaustedRetries = false;
@@ -341,10 +349,15 @@
public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
             // the aggregated output runs in another unit of work
             Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
 
+            // remove the complete all groups headers as it should not be on the copy
+            copy.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP);
+            copy.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS);
+            copy.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE);
+
             // when memory based then its fast using synchronized, but if the aggregation repository is IO
             // bound such as JPA etc then concurrent aggregation per correlation key could
             // improve performance as we can run aggregation repository get/add in parallel
-            List<Exchange> aggregated = null;
+            List<Exchange> aggregated;
             lock.lock();
             try {
                 aggregated = doAggregation(key, copy);
@@ -362,6 +375,8 @@
public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
         // check for the special header to force completion of all groups (inclusive of the message)
         boolean completeAllGroupsInclusive = exchange.getIn().getHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE, false, boolean.class);
         if (completeAllGroupsInclusive) {
+            // remove the header so we do not complete again
+            exchange.getIn().removeHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE);
             forceCompletionOfAllGroups();
         }
     }
